import React from 'react'

class Com extends React.Component {
    componentDidMount() {

    }
    state = {
        num: 0,
        text: 0,
    }
    componentWillUpdate() {
        console.log("componentWillUpdate")
    }
    render() {
        return (
            <div>
                <h1>类组件</h1>
                <h2>{this.state.num}</h2>
                <h2>{this.state.text}</h2>
                <button type="button" onClick={() => {
                    this.setState({
                        num: (this.state.num + 1)
                    })
                    this.setState((state:any) => {
                        return { text: state.text+1 }
                    }, () => {
                        console.log("回调函数")
                    })
                }}>点击</button>
            </div>
        );
    }
}

export default Com